package com.ruoyi.biz.api.organization.factory;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.biz.api.organization.RemoteCompanyService;
import com.ruoyi.common.core.domain.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class RemoteCompanyFallbackFactory implements FallbackFactory<RemoteCompanyService> {
    @Override
    public RemoteCompanyService create(Throwable cause) {
        log.error("服务调用失败:{}", cause.toString());
        return new RemoteCompanyService() {
            @Override
            public R add(JSONObject jsonObject) {
                return R.fail("保存企业失败");
            }
        };
    }
}
